import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class IosAlertDialog extends StatefulWidget {
  final String title;
  final String desText;
  final Function confirmCallback;

  const IosAlertDialog(
      {Key? key,
      required this.title,
      required this.desText,
      required this.confirmCallback})
      : super(key: key);

  @override
  _IosAlertDialogState createState() => _IosAlertDialogState();
}

class _IosAlertDialogState extends State<IosAlertDialog> {
  @override



  _iosDialog() async {
    var alertDialogs = await showDialog(
        context: context,
        builder: (context) {
          return CupertinoAlertDialog(
            title: Text(widget.title),
            content: Column(
              children: [
                SizedBox(
                  height: 10,
                ),
                Align(
                  child: Text(widget.title),
                  alignment: Alignment(0, 0),
                )
              ],
            ),
            actions: [
              CupertinoDialogAction(
                child: Text('取消'),
                onPressed: () {
                  Navigator.pop(context);
                },
              ),
              CupertinoDialogAction(
                child: Text('确定'),
                onPressed: () {
                  Navigator.pop(context);
                },
              ),
            ],
          );
        });
    return alertDialogs;
  }




  Widget build(BuildContext context) {
    return Container(
    //   color: Colors.red,
    //   child: CupertinoAlertDialog(
    //     title: Text(widget.title),
    //     content: Column(
    //       children: [
    //         SizedBox(
    //           height: 10,
    //         ),
    //         Align(
    //           child: Text(widget.desText),
    //           alignment: Alignment(0, 0),
    //         )
    //       ],
    //     ),
    //     actions: [
    //       CupertinoDialogAction(
    //         child: Text('取消'),
    //         onPressed: () {
    //           Navigator.pop(context);
    //         },
    //       ),
    //       CupertinoDialogAction(
    //         child: Text('确定'),
    //         onPressed: () {
    //           Navigator.pop(context);
    //           widget.confirmCallback();
    //         },
    //       ),
    //     ],
    //   ),
    );
  }
}















/// 自定义
class CustomDialog extends StatefulWidget {
  final String title;
  final String desText;
  final Function confirmCallback;

  const CustomDialog(
      {Key? key,
      required this.title,
      required this.desText,
      required this.confirmCallback})
      : super(key: key);

  @override
  _CustomDialogState createState() => _CustomDialogState();
}

class _CustomDialogState extends State<CustomDialog> {
  @override
  Widget build(BuildContext context) {
    return SimpleDialog(
      titlePadding: EdgeInsets.only(top: 15, bottom: 5),
      title: Center(
        child: Text(widget.title),
      ),
      backgroundColor: Colors.white,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
      children: [
        Divider(
          height: 1,
        ),
        Container(
          alignment: Alignment.center,
          height: 80,
          child: Text(widget.desText,
              style: TextStyle(fontSize: 17, color: Colors.black)),
        ),
        Container(
            child: Row(
          children: [
            Expanded(
              flex: 2,
              child: TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: Container(
                  alignment: Alignment.center,
                  height: 50,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(10),
                    color: Colors.white,
                    border: Border.all(color: Color(0xffFF4B38), width: 1),
                  ),
                  child: Text('否',
                      style: TextStyle(color: Color(0xffFF4B38), fontSize: 17)),
                ),
              ),
            ),
            Expanded(
                flex: 3,
                child: TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                      widget.confirmCallback();
                    },
                    child: Container(
                      alignment: Alignment.center,
                      height: 50,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(10),

                        color: Color(0xffFF4B38),

                        // border: Border.all(color: Color(0xffFF4B38),width: 1),
                      ),
                      child: Text('是',
                          style: TextStyle(color: Colors.white, fontSize: 17)),
                    )))
          ],
        ))
      ],
    );
  }
}
